﻿Imports System.Runtime.CompilerServices
Imports System.ComponentModel

Public Module MyInvoke
    <Extension()> _
    Public Sub CustomInvoke(Of T As ISynchronizeInvoke)(ByVal control As T, ByVal toPerform As Action(Of T))
        If control.InvokeRequired Then
            control.Invoke(toPerform, New Object() {control})
        Else
            toPerform(control)
        End If
    End Sub
End Module
